3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
To illustrate the differences among the three types of metafile-- stream, normal, and database--we show how a single model ( Figure 2 ) is described in a text file of each type. The model consists of four occurrences (at different locations) of a colored box.
Figure 2 Four instantiations of a box
The following is a complete specification of each colored box shown in Figure 2 :
3DMetafile ( 1 5 Normal tableofcontents0> )
box2:
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
attributeset3:
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
The expression Container (...) is used subsequently to abbreviate this specification. Transforms are used to place the box in various positions.
In a stream file, the specification of the box must occur four times, as shown in Listing 3 .
3DMetafile ( 1 5 Stream
tableofcontents0> )
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
Translate ( 3 0 0 )
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
Translate ( 0 3 0 )
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
Translate ( -3 1 0 )
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
Such repetition can make stream files lengthy. However, a stream file can be read by a parser having only sequential access to that file.
In a normal file, the box is completely specified once and is instantiated by reference three times. The file pointers and reference objects used to effect instantiations by reference are listed together in the table of contents. Other objects able to be referenced (such as the transforms) that are instantiated once only are not listed in the table of contents. The normal metafile permits the most compact representation of the model.
3DMetafile ( 1 5 Normal tableofcontents0> )
box2:
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
attributeset3:
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
translate4:
Translate ( 3 0 0 )
Reference ( 1 )
translate5:
Translate ( 0 3 0 )
Reference ( 1 )
translate6:
Translate ( -3 1 0 )
Reference ( 1 )
tableofcontents0:
TableOfContents (
tableofcontents1> # next TOC
2 # reference seed
-1 # typeSeed
1 # tocEntryType
16 # tocEntrySize
1 # nEntries
1 box2>
Box
)
The pointer box2> is a file pointer correlated with the label box2 that precedes the specification of the box. Reference ( 1 ) is a reference object correlated with box2> (and thus with the specification of the box) in the table of contents. See "File Pointers" for an explanation of how instantiation by reference is accomplished through the use of these objects.
In a database file, the box is also instantiated by reference, and the file pointers and reference objects used to instantiate it are listed in the table of contents. With the exception of reference objects themselves, all other objects able to be referenced (the attribute set which contains the box's color attributes, and the transforms) are referenced, and all of these references are listed in the table of contents.
The contents of a database file can be discovered quickly by inspecting its tables of contents.
3DMetafile ( 1 5 Database
tableofcontents0> )
box2:
Container (
Box (
0 0 1 # orientation
1 0 0 # majorAxis
0 0 0 # minorAxis
0 1 0 # origin
)
attributeset3:
Container (
AttributeSet ( )
DiffuseColor ( 0.9 0.9 0.2 )
)
)
translate4:
Translate ( 3 0 0 )
Reference ( 1 )
translate5:
Translate ( 0 3 0 )
Reference ( 1 )
translate6:
Translate ( -3 1 0 )
Reference ( 1 )
tableofcontents0:
TableOfContents (
tableofcontents1> # next TOC
6 # reference seed
-1 # typeSeed
1 # tocEntryType
16 # tocEntrySize
5 # nEntries
1 box2>
Box
2 attributeset3>
AttributeSet
3 translate4>
Translate
4 translate5>
Translate
5 translate6>
Translate
)
Figure 3 shows, side by side, the three principal forms of a metafile.
Previous | QD3D Book | Overview | Chapter Contents | Next |